View Javadoc
1 /* 2 Java Regular Expressions Plugin API 3 4 Copyright (C) 2002 Jose San Leandro Armend?riz 5 jsanleandro@yahoo.es 6 chousz@yahoo.com 7 8 This library is free software; you can redistribute it and/or 9 modify it under the terms of the GNU Lesser General Public 10 License as published by the Free Software Foundation; either 11 version 2.1 of the License, or (at your option) any later version. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with this library; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 22 Thanks to ACM S.L. for distributing this library under the LGPL license. 23 Contact info: jsr000@terra.es 24 Postal Address: c/Playa de Lagoa, 1 25 Urb. Valdecaba?as 26 Boadilla del monte 27 28660 Madrid 28 Spain 29 30 This library uses some external APIs. So far I haven't released such 31 APIs as projects themselves, but you should be able 32 to download them from the web page where you got this source code. 33 34 ****************************************************************************** 35 * 36 * Filename: $RCSfile: HelperJDKAdapter.java,v $ 37 * 38 * Author: Jose San Leandro Armend?riz 39 * 40 * Description: Jakarta Helper-specific regexp helper adapter. 41 * 42 * Last modified by: $Author: chous $ at $Date: 2003/06/21 21:07:26 $ 43 * 44 * File version: $Revision: 1.2 $ 45 * 46 * Project version: $Name: $ 47 * ("Name" means no concrete version has been checked out) 48 * 49 * $Id: HelperJDKAdapter.java,v 1.2 2003/06/21 21:07:26 chous Exp $ 50 * 51 */ 52 package org.acmsl.regexpplugin.jdk14regexp; 53 54 /* 55 * Importing project-specific classes. 56 */ 57 import org.acmsl.regexpplugin.Helper; 58 import org.acmsl.regexpplugin.MalformedPatternException; 59 60 /* 61 * Importing some ACM-SL classes. 62 */ 63 import org.acmsl.version.Version; 64 import org.acmsl.version.VersionFactory; 65 66 /* 67 * Importing JDK1.4 classes. 68 */ 69 import java.util.regex.PatternSyntaxException; 70 71 /*** 72 * Jakarta ORO-specific regexp helper adapter. 73 * @author <a href="mailto:jsanleandro@yahoo.es" 74 >Jose San Leandro Armend?riz</a> 75 * @version $Revision: 1.2 $ 76 */ 77 public class HelperJDKAdapter 78 implements Helper 79 { 80 /*** 81 * Finds all occurrences of a specified pattern in given input contents, 82 * and replaces them with passed String. 83 * @param input the input text to process. 84 * @param pattern the pattern to replace. 85 * @param replacement the replacement text. 86 * @return the updated input. 87 * @throws MalformedPatternException if given regexp is malformed. 88 */ 89 public String replaceAll(String input, String pattern, String replacement) 90 throws MalformedPatternException 91 { 92 String result = input; 93 94 if ( (input != null) 95 && (pattern != null) 96 && (replacement != null)) 97 { 98 try 99 { 100 result = input.replaceAll(pattern, replacement); 101 } 102 catch (PatternSyntaxException patternSyntaxException) 103 { 104 throw 105 new MalformedPatternExceptionJDKAdapter( 106 patternSyntaxException); 107 } 108 } 109 110 return result; 111 } 112 113 /*** 114 * Concrete version object updated everytime it's checked-in in a CVS 115 * repository. 116 */ 117 public static final Version VERSION = 118 VersionFactory.createVersion("$Revision: 1.2 $"); 119 120 /*** 121 * Retrieves the current version of this object. 122 * @return the version object with such information. 123 */ 124 public Version getVersion() 125 { 126 return VERSION; 127 } 128 129 /*** 130 * Retrieves the current version of this class. 131 * @return the object with class version information. 132 */ 133 public static Version getClassVersion() 134 { 135 return VERSION; 136 } 137 }

This page was automatically generated by Maven